package com.wx.app.card.dao.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.wx.app.card.dao.entity.FriendEntity;
import com.wx.app.card.domain.vo.RankSerialVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 类功能描述：
 *
 * @author：刘富国
 * @createTime：2019/7/22 22:51
 */
@Mapper
public interface FriendMapper extends BaseMapper<FriendEntity> {


    @Select("SELECT f.friend_user_id as userId, u.nick_name as nickName, u.head_img as headImg, u.max_score as maxScore\n" +
            "FROM t_friend f LEFT JOIN t_user u ON u.id = f.friend_user_id \n" +
            "WHERE f.user_id = #{userId} and u.nick_name IS NOT NULL ORDER BY u.max_score DESC")
    List<RankSerialVO> getFriendRankSerial(@Param("userId") Long userId);

    @Select("SELECT id as userId, nick_name as nickName, head_img as headImg, max_score as maxScore\n" +
            "FROM t_user where nick_name IS NOT NULL\n" +
            "ORDER BY max_score DESC  LIMIT 100")
    List<RankSerialVO> getAllRankSerial();

}
